import time


def cal_time(fn):
    print('cal_timing...')
    print('fn = {}'.format(fn))

    def inner():
        start = time.time()
        fn()
        end = time.time()
        print('cost {}s'.format(end - start))

    return inner


@cal_time  # @cal_time做了几件事1.调用cal_time() 2.将func0传给cal_time
def func0():
    time.sleep(3)
    print('func0')


print('装饰后的func0 = {}'.format(func0))  # 3.此时的func变成了cal_time的返回值inner函数
func0()
